var szk = {id:{link:"link",xem:"player",dx:"dangxem",sv:"server"}, site:{tc:"clip.bay68.com",get:"9367cfcd147285f439ea96ed453791c0",hl:/hc\*/g}, lsv:{svl:"youtube.com",svt:"Trận"}}
// Modum Write Server //
var $_  = function(x){return document.getElementById(x);}
var sv  = (szk.lsv.svl).split(',');
var ten_sv  = (szk.lsv.svt).split(',');

home = szk.site.tc;

// Query String --
String.prototype.GetPart = function(para) {
var reg = new RegExp("(^|&)"+ para +"=([^&]*)(&|$)");
var r = this.substr(this.indexOf("\?")+1).match(reg);
if (r!=null) return unescape(r[2]); return null;
}
// ANCMedia Object //
function ANCMedia(){
var dl = szk.id.link; 
var pl = szk.id.xem; 
var tp = szk.id.sv; 
var playing = szk.id.dx;

//Data -- CSDL;
function Read(){
	m_data = $_(dl).innerHTML;
	r_left = '<div id="r_data" style="display:none !important;" title="Data here !">';
	r_right = '</div>';
	m_data = m_data.replace(/\<id\>/gi,r_left);
	m_data = m_data.replace(/\<\/id\>/gi,r_right);
	$_(dl).innerHTML = m_data;	
	m_data = $_("r_data").innerHTML;
	return m_data;
}
data = Read();
//Write -- CSDL;
l_spi = data.split('|').length ;
l_spk = function(x){return data.split('|')[x].split(';').length;}
d_spi = function(x){ return data.split('|')[x]};
d_spk = function(x,y){return data.split('|')[x].split(';')[y];}
part = new Array();
pc =["0","A","B","C","D","E","F","G","H","I","K","L","M","N","O","P","Q","R","S"],ab="",part_ep="";
data_out = "";

this.Play = function(){
//1-- Add server name

for(var s = 0; s < ten_sv.length; s++){var srv = ten_sv[s].split('.')[0];if(srv == ""){srv = home;}part[s] = '<li class="sev">Video '+srv+':</li>';}
//2-- Write server name
for(var i=0; i< l_spi; i++){
// -- Tên tập hoặc phần
name_ep = d_spk(i,0);
for(var j=0; j< l_spk(i);j++){
// -- Link 
link_ep = d_spk(i,j);
// -- Dat ten cho các phan
number_ep = Number(d_spk(i,0)); number_epp =""; if(i>0){number_epp = Number(d_spk((i-1),0));}
if(l_spk(i)==2){ab=""; part_ep="";}else{ ab = pc[j]; part_ep = "-"+j;}
(number_ep)?
	name_eppart = name_ep+ab:
	name_eppart = name_ep + part_ep;		
if(d_spk(i,j) != ""){	
for(var s = 0; s< sv.length; s++){
(d_spk(i,j).indexOf(sv[s]) != -1)?
part[s] += '<li onclick="M.Load(\''+link_ep+'\',\''+name_eppart+'\');" class="ep"><a class="a_tap" rel="'+home+':'+name_eppart+'" title="Trận '+name_eppart+'" href="?p='+i+'/'+j+'/'+name_eppart.replace(/ /gi,"_")+'">&nbsp;'+name_eppart+'&nbsp;</a></li><!--ANCMedia Part-->':false;	
}}}}
//3-- Check server Emty
data_out += '<div id="list_tap">';
if(l_spi >= 2){
	for(var s = 0; s < sv.length; s++){
		(part[s].indexOf("ANCMedia") != -1)?data_out += "<ul id='"+s+"'>"+part[s]+"<div style='clear:both;' ></div></ul>":false;
	}
}else{
data_out += '<ul><li class="sev">Video Trận:</li>'
		 +	'<li class="ep"><a class="a_tap" rel="'+home+': Xem Full trận" title="Xem Full trận" href="javascript:M.Load(\''+data+'\',\'Full_time\');">Xem Full trận</a></li></ul>'
}
data_out += '<div class="clear" /></div>';
//4-- Total
$_(tp).innerHTML = data_out;
}


this.Load = function(x,y){
obj = "",name_ep = "";

if(x.indexOf(sv[0]) != -1){obj = DBOj(x)[0];} 

if(Number(y)){name_ep = "<span>Đang xem trận:</span> "+y+"";}
else if(y.length >=5 ){name_ep = "<span>Đang xem trận:</span> "+y+"";}
else if(!Number(y) && y.length < 5){name_ep = "<span>Đang xem trận:</span> "+y+"";}
$_(pl).innerHTML = obj;
$_(playing).innerHTML = name_ep;

}

//Query String..
this.Qstr = function(){

str = window.location.href; 
part = str.GetPart("p");
(part==null)?part = "0/1/"+d_spk(0,0)+"":false;
a = part.split('/')[0];
b = part.split('/')[1];
c = decodeURI(part.split('/')[2]);
(l_spi >= 2)?this.Load(d_spk(a,b),c):this.Load(data,'Full_time');
}
}
	
var DBOj = function(x){
	return obj = [
	'<object width="100%" height="100%" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"><param name="movie" value="'+x+'?modestbranding=1&version=3&hl=vi_VN&rel=0&autoplay=1&showsearch=0&iv_load_policy=3""></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="'+x+'?modestbranding=1&version=3&hl=vi_VN&rel=0&autoplay=1&showsearch=0&iv_load_policy=3"" type="application/x-shockwave-flash" width="100%" height="100%" wmode="window" allowfullscreen="true" allownetworking="internal"></embed></object>'
	];
	
}

M = new ANCMedia(); M.Play(),M.Qstr();